<!--
Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

-->
<!--
TinyMCE configurations are taken from the TinyMCE samples 
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Text Editor</title>
<script language="javascript" src="tiny_mce/tiny_mce_src.js"></script>

<?php

$text_comp_id = $_GET["text_comp_id"];

?>

<script language="javascript">

function init()
{
	var textCompId = "<?php echo $text_comp_id; ?>";
	
	if(textCompId != "") //this means it is just uploaded it..
	{
		var textComp = parent.document.getElementById(textCompId);
		var content = textComp.value;
		
		var elm1 = document.getElementById('elm1')
		elm1.innerHTML = content;
		//set the value of the current control
	}
}

function saveThis(content)
{
	var textCompId = "<?php echo $text_comp_id; ?>";
	
	if(textCompId != "") //this means it is just uploaded it..
	{
		var textComp = parent.document.getElementById(textCompId);
		//set the value of the current control
		textComp.value = content;
		if(textComp.onchange)
		{
			textComp.onchange(); //just trigger the control to update..
		}
	}

}
</script>

<script language="javascript">
	tinyMCE.init({
		mode : "exact",
		theme : "advanced",
		elements : "elm1",
		plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,fullscreen",
		theme_advanced_buttons1_add_before : "save,newdocument,separator",
		theme_advanced_buttons1_add : "fontselect,fontsizeselect",
		theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
		theme_advanced_buttons3_add_before : "tablecontrols,separator",
		theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		content_css : "example_word.css",
	    plugi2n_insertdate_dateFormat : "%Y-%m-%d",
	    plugi2n_insertdate_timeFormat : "%H:%M:%S",
		external_link_list_url : "example_link_list.js",
		external_image_list_url : "example_image_list.js",
		media_external_list_url : "example_media_list.js",
		file_browser_callback : "fileBrowserCallBack",
		save_callback : "save_callback",
		paste_use_dialog : false,
		theme_advanced_resizing : true,
		theme_advanced_resize_horizontal : false,
		theme_advanced_link_targets : "_something=My somthing;_something2=My somthing2;_something3=My somthing3;",
		paste_auto_cleanup_on_paste : true,
		paste_convert_headers_to_strong : false,
		paste_strip_class_attributes : "all",
		paste_remove_spans : false,
		paste_remove_styles : false	
	});
	
	counter = 0;

	function save_callback(id, content)
	{
		//alert(parent.SEMF.pageDesigner.pageInfo.currentComponent);
		counter ++;
		if( counter == 2)
		{
			counter = 0;
			saveThis(content);
		}
		//alert(content);
		return 1;
	}
	
	function fileBrowserCallBack(field_name, url, type, win) {
		// This is where you insert your custom filebrowser logic
		alert("Filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);

		// Insert new URL, this would normaly be done in a popup
		win.document.forms[0].elements[field_name].value = "someurl.htm";
	}
	
	
</script>
</head>
<body>

<body>
<form id="elm1form" name="elm1form">
	<div  id="elm1" name="elm1" rows="18" cols="70" style="width: 100%; height:250px">
	</div>
</form>
<script>
init();
</script>
</body>
</html>
